<!--
 * @Author: xiuquanxu
 * @Company: kaochong
 * @Date: 2021-01-06 20:26:29
 * @LastEditors: xiuquanxu
 * @LastEditTime: 2021-01-06 20:29:25
-->
<html>
    <meta charset="utf-8"/>
    <body>
        <h1>自定义事件</h1>
    </body>
    <script>
        const event = new Event('SelfEvent');
        const el = document.querySelector('h1');
        el.addEventListener('SelfEvent', function(e) {
            console.log('emit self event', e.target);
        });
        el.dispatchEvent(event);
    </script>
</html>